<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JS继承</title>
</head>
<body>
<p>使用 "super" 方法调用父级的构造函数。</p>
<p id="demo"></p>

<script>
    class Car{
        constructor(brand) {
            this.carname = brand;
        }
        present(){
            return 'I have a ' + this.carname;
        }
    }
    class Model extends Car{
        constructor(brand,mod) {
            super(brand);
            this.model = mod;
        }
        show(){
            return this.present() + ', it is a ' + this.model;
        }
    }

    let myCar = new Model("Ford", "Mustang");
    document.getElementById("demo").innerHTML = myCar.show();
</script>
</body>
</html>